stage.create_grid_overlay(50, "blue")
target = codesters.Sprite("triangle", 100, 50)
target.set_opacity(.5)
display = codesters.Text("Click the triangle to show rotation about the origin!", 0, 225, "green")
def click(sprite):
display.set_text('Click your new triangle to show the next rotation.')
target.rotate_origin(90)
new_x = target.get_x()
new_y = target.get_y()
sprite2 = codesters.Sprite("triangle", new_x, new_y)
sprite2.set_speed(100)
rotation = target.get_rotation()
sprite2.turn_left(rotation)
text = codesters.Text("Rotation = " + str(rotation), new_x, new_y -30)
if rotation == 360:
display.set_text("Great job! That's 360 degrees!")
target.event_click(click)
# stage.create_grid_overlay(line_separation, "line_color")
stage.create_grid_overlay(50, "grey")
sprite = codesters.Sprite("triangle", 100, 50)
sprite.set_speed(1)
# if target.get_x() == 0 and target.get_rotation() == 0:
# display = codesters.Text("Click the triangle to show rotation abot the origin!", 0, 200, "green")
# elif target.get_x() == -50 and target.get_rotation() == 90:
# display.set_text('Click your new triangle to show the next rotation.')
# elif target.get_x() == -100 and target.get_rotation() == 180:
# display.set_text('Click your new triangle to show the next rotation.')
# elif target.get_x() == 50 and target.get_rotation() == 270:
# display.set_text('Click your new triangle to show the next rotation.')
# elif target.get_x() == 100 and target.get_rotation() == 360:
# display.set_text('Click your new triangle to show the next rotation.')
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)